import request from '@/utils/request'
// 新闻列表
export function getNewList(params) {
  return request({
    url: '/newslist',
    method: 'get',
    params
  })
}
// 单条新闻
export function getOneNews(id) {
  return request({
    url: `/news/${id}`,
    method: 'get'
  })
}

// 修改新闻
export function updateOneNews(id, body) {
  return request({
    url: `/news/${id}`,
    method: 'put',
    data: body
  })
}

// 增加新闻
export function addNews(params) {
  return request({
    url: '/news',
    method: 'post',
    data: params
  })
}
// 上传封面
export function uploadCover(params) {
  var formData = params
  return request({
    url: '/upload/news',
    method: 'post',
    'Content-Type': 'multipart/form-data',
    data: formData
  })
}
// 删除新闻
export function delNews(id) {
  return request({
    url: `/news/${id}`,
    method: 'delete'
  })
}
